#!/usr/bin/env python
#-*- coding: utf-8 -*-

# Copyright 2009 Larry Resnik, Lasfraka-Elixir

#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.

#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.

#   You should have received a copy of the GNU General Public License
#   along with this program.  If not, see <http://www.gnu.org/licenses/>.


from engine import config
from pyglet.window import key
import unittest

class TestConfigKeyIO(unittest.TestCase):
    def setUp(self):
        self.settings = config.Settings()

    def testgetKeyValueWithValidName(self):
        self.assertEqual(self.settings.get_key_value('A'), 97)

    def testgetKeyValueWithValidUserKey(self):
        self.assertEqual(self.settings.get_key_value(key.user_key(99)),
            425201762304L)

    def testgetKeyValueWithInvalidName(self):
        self.assertRaises(ValueError, self.settings.get_key_value('AL'))

    def testgetKeyNameWithUserKey(self):
        self.assertEqual(self.settings.get_key_name(key.user_key(99)),
            '425201762304L')

    def testgetKeyNameWithValidName(self):
        self.assertEqual(self.settings.get_key_name(97), 'A')

    def testgetKeyNameWithInvalidName(self):
        self.assertEqual(self.settings.get_key_name(2000), '2000')

if __name__ == '__main__':
    unittest.main()
